home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
cpphtp2
/
code.jar
/
code
/
ch03
/
fig03_23.txt
< prev
next >
Wrap
Text File
|
1998-02-27
|
846b
|
26 lines
1 // Fig. 3.23: fig03_23.cpp
2 // Using default arguments
3 #include <iostream.h>
4
5 int boxVolume( int length = 1, int width = 1, int height = 1 );
6
7 int main()
8 {
9 cout << "The default box volume is: " << boxVolume()
10 << "\n\nThe volume of a box with length 10,\n"
11 << "width 1 and height 1 is: " << boxVolume( 10 )
12 << "\n\nThe volume of a box with length 10,\n"
13 << "width 5 and height 1 is: " << boxVolume( 10, 5 )
14 << "\n\nThe volume of a box with length 10,\n"
15 << "width 5 and height 2 is: " << boxVolume( 10, 5, 2 )
16 << endl;
17
18 return 0;
19 }
20
21 // Calculate the volume of a box
22 int boxVolume( int length, int width, int height )
23 {
24 return length * width * height;
25 }